import cv2
import matplotlib.pyplot as plt
import numpy as np

img = cv2.imread("../images/zhifangtu.png", cv2.IMREAD_GRAYSCALE)
plt.hist(
    img.flatten(),
    bins=256,
    range=(0,256),
    density=True
)
plt.show()

# 进行普通原始直方图均衡化
img_equalize = cv2.equalizeHist(img)
plt.hist(
    img_equalize.flatten(),
    bins=256,
    range=(0,256),
    density=True
)
plt.show()

img_stack = np.hstack([img, img_equalize])
cv2.imshow("img_stack", img_stack)
cv2.waitKey(0)